package com.loongtech.bi.action.authManagement;

import com.loongtech.bi.entity.system.EntitySysProject;
import com.loongtech.bi.manager.system.SysProjectManager;
import com.loongtech.core.util.RetCode;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author: yuri
 * Description: 游戏项目管理
 * Date: 18:09 2017/4/25
 */
@RestController
@Scope("prototype")
@RequestMapping("/project")
public class SysProjectAction {
    @Resource
    private SysProjectManager sysProjectManager;

    @RequestMapping(value = "list.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ResultData<?> list() {
        ResultData<List<EntitySysProject>> res = new ResultData<>(RetCode.eSuccess.getErrorcode(), sysProjectManager.queryList());
        return sysProjectManager.queryList() == null ? ResultData.otherException() : res;
    }

    /**
     * 增加
     */
    @RequestMapping(value = "add.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ResultData<String> add(EntitySysProject project) {
        RetCode ret = sysProjectManager.addProject(project);
        return new ResultData<>(ret.getErrorcode(), ret.getErrorMsg());
    }

    /**
     * 删除
     */
    @RequestMapping(value = "delete.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ResultData<String> delete(Integer id) {
        RetCode ret = sysProjectManager.delProject(id);
        return new ResultData<>(ret.getErrorcode(), ret.getErrorMsg());
    }

    /**
     * 修改
     */
    @RequestMapping(value = "modify.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ResultData<String> modifiy(EntitySysProject e) {
        RetCode ret = sysProjectManager.modifyProject(e);
        return new ResultData<>(ret.getErrorcode(), ret.getErrorMsg());
    }
}
